/**
 * This file is part of the CAKIS project.
 * 
 * Copyright (c) 2009-2010 - Florian Arndt, Christian Kerl
 * 
 * @license GNU Lesser General Public License v3 <http://www.opensource.org/licenses/lgpl-3.0.html>
 * @since   04.05.2010
 * @version SVN: $Id: CustomItemClass.java 106 2010-05-06 18:59:51Z f.aarndt@web.de $
 */

package org.cakis.client;

import javax.microedition.lcdui.CustomItem;
import javax.microedition.lcdui.Graphics;

import org.cakis.client.forms.VideoForm;

/**
 * CustomItemClass
 *
 * @author Florian Arndt
 */
public class CustomItemClass extends CustomItem {
	private SnapshotThread snapshotThread;
	
	public CustomItemClass(CakisMIDlet cakisMIDlet, VideoForm vidForm) {
		super("");
	    snapshotThread = new SnapshotThread(cakisMIDlet, vidForm);
	    new Thread(snapshotThread).start();
	}

	public int getMinContentWidth() {
		return 0;
	}

	public int getMinContentHeight() {
		return 0;
	}

	public int getPrefContentWidth(int width) {
		return getMinContentWidth();
	}

	public int getPrefContentHeight(int height) {
		return getMinContentHeight();
	}

	public void paint(Graphics g, int w, int h) {
		
	}

	protected void keyPressed(int keyCode) {
	    // Any valid game key will trigger a capture
		// System.out.println("code is as - "+keyCode);
	    if (getGameAction(keyCode) != 0) {
	      snapshotThread.continueRun();
	    } else {
	      super.keyPressed(keyCode);
	    }
	}
}
